<!DOCTYPE html>
        <html>
        <head>
            <meta charset="UTF-8">
            <title>&#x7b2c;&#x56db;&#x7ae0; &#x7cfb;&#x7edf;&#x96c6;&#x6210;Jenkins</title>
            <style>
/* From extension vscode.github */
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

.vscode-dark img[src$=\#gh-light-mode-only],
.vscode-light img[src$=\#gh-dark-mode-only],
.vscode-high-contrast:not(.vscode-high-contrast-light) img[src$=\#gh-light-mode-only],
.vscode-high-contrast-light img[src$=\#gh-dark-mode-only] {
	display: none;
}

</style>
            <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex/dist/katex.min.css">
<link href="https://cdn.jsdelivr.net/npm/katex-copytex@latest/dist/katex-copytex.min.css" rel="stylesheet" type="text/css">
        <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/Microsoft/vscode/extensions/markdown-language-features/media/markdown.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/Microsoft/vscode/extensions/markdown-language-features/media/highlight.css">
<style>
            body {
                font-family: -apple-system, BlinkMacSystemFont, 'Segoe WPC', 'Segoe UI', system-ui, 'Ubuntu', 'Droid Sans', sans-serif;
                font-size: 14px;
                line-height: 1.6;
            }
        </style>
        <style>
.task-list-item {
    list-style-type: none;
}

.task-list-item-checkbox {
    margin-left: -20px;
    vertical-align: middle;
    pointer-events: none;
}
</style>
<style>
:root {
  --color-note: #0969da;
  --color-tip: #1a7f37;
  --color-warning: #9a6700;
  --color-severe: #bc4c00;
  --color-caution: #d1242f;
  --color-important: #8250df;
}

</style>
<style>
@media (prefers-color-scheme: dark) {
  :root {
    --color-note: #2f81f7;
    --color-tip: #3fb950;
    --color-warning: #d29922;
    --color-severe: #db6d28;
    --color-caution: #f85149;
    --color-important: #a371f7;
  }
}

</style>
<style>
.markdown-alert {
  padding: 0.5rem 1rem;
  margin-bottom: 16px;
  color: inherit;
  border-left: .25em solid #888;
}

.markdown-alert>:first-child {
  margin-top: 0
}

.markdown-alert>:last-child {
  margin-bottom: 0
}

.markdown-alert .markdown-alert-title {
  display: flex;
  font-weight: 500;
  align-items: center;
  line-height: 1
}

.markdown-alert .markdown-alert-title .octicon {
  margin-right: 0.5rem;
  display: inline-block;
  overflow: visible !important;
  vertical-align: text-bottom;
  fill: currentColor;
}

.markdown-alert.markdown-alert-note {
  border-left-color: var(--color-note);
}

.markdown-alert.markdown-alert-note .markdown-alert-title {
  color: var(--color-note);
}

.markdown-alert.markdown-alert-important {
  border-left-color: var(--color-important);
}

.markdown-alert.markdown-alert-important .markdown-alert-title {
  color: var(--color-important);
}

.markdown-alert.markdown-alert-warning {
  border-left-color: var(--color-warning);
}

.markdown-alert.markdown-alert-warning .markdown-alert-title {
  color: var(--color-warning);
}

.markdown-alert.markdown-alert-tip {
  border-left-color: var(--color-tip);
}

.markdown-alert.markdown-alert-tip .markdown-alert-title {
  color: var(--color-tip);
}

.markdown-alert.markdown-alert-caution {
  border-left-color: var(--color-caution);
}

.markdown-alert.markdown-alert-caution .markdown-alert-title {
  color: var(--color-caution);
}

</style>
        
        </head>
        <body class="vscode-body vscode-light">
            <h1 id="第四章-系统集成jenkins">第四章 系统集成Jenkins</h1>
<h2 id="1-安装ldap">1. 安装LDAP</h2>
<ul>
<li>参考文档：<a href="https://www.cnblogs.com/mascot1/p/10498392.html">https://www.cnblogs.com/mascot1/p/10498392.html</a></li>
</ul>
<h3 id="11-先决条件">1.1 先决条件</h3>
<pre><code>#关闭SELINUX
vim /etc/sysconfig/selinux   # SELINUX=disabled
setenforce 0 

#关闭防火墙
systemctl stop firewalld	
systemctl disable firewalld

</code></pre>
<h3 id="12-安装ldap">1.2 安装ldap</h3>
<pre><code>#安装ldap工具
yum install -y openldap-servers openldap-clients migrationtools  
slappasswd   #据提示输入密码会返回加密的密码字符串，保存好这个字符串

#配置数据库缓存
cp /usr/share/openldap-servers/DB_CONFIG.example /var/lib/ldap/DB_CONFIG 
chown -R ldap:ldap /var/lib/ldap/

#测试配置文件
slaptest -u  #出现configfile testing successed 说明成功了

#启动ldap
systemctl start slapd.service 
systemctl enable slapd.service

#导入模板
ls /etc/openldap/schema/*.ldif | xargs -I {} sudo ldapadd -Y EXTERNAL -H ldapi:/// -f {}
</code></pre>
<h2 id="2-安装ldap控制台">2. 安装LDAP控制台</h2>
<h3 id="21-先决条件">2.1 先决条件</h3>
<pre><code>#安装apache
yum -y install httpd 

#修改配置文件
vim /etc/httpd/conf/httpd.conf #AllowOverride all

#启动服务测试
systemctl start httpd
systemctl enable httpd
    curl 127.0.0.1

</code></pre>
<h3 id="22-安装phpldapadmin">2.2 安装phpldapadmin</h3>
<pre><code>yum update -y
yum install -y epel-release
yum install -y phpldapadmin
</code></pre>
<h3 id="23-更改配置文件">2.3 更改配置文件</h3>
<p>slappasswd
New password:
Re-enter new password:
{SSHA}EdgbJXgA8bTDv5Csu1bsVS/bIM4KUTy/</p>
<p>cd /etc/openldap/slapd.d</p>
<p>vim db.ldif
dn: olcDatabase={2}hdb,cn=config
changetype: modify
replace: olcSuffix
olcSuffix: dc=sy,dc=com</p>
<p>dn: olcDatabase={2}hdb,cn=config
changetype: modify
replace: olcRootDN
olcRootDN: cn=admin,dc=sy,dc=com</p>
<p>dn: olcDatabase={2}hdb,cn=config
changetype: modify
replace: olcRootPW
olcRootPW: {SSHA}EdgbJXgA8bTDv5Csu1bsVS/bIM4KUTy/</p>
<p>ldapmodify -Y EXTERNAL -H ldapi:/// -f db.ldif
SASL/EXTERNAL authentication started
SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
SASL SSF: 0
modifying entry &quot;olcDatabase={2}hdb,cn=config&quot;</p>
<p>modifying entry &quot;olcDatabase={2}hdb,cn=config&quot;</p>
<p>modifying entry &quot;olcDatabase={2}hdb,cn=config&quot;</p>
<p>vim monitor.ldif
dn: olcDatabase={1}monitor,cn=config
changetype: modify
replace: olcAccess
olcAccess: {0}to * by dn.base=&quot;gidNumber=0+uidNumber=0,cn=peercred,cn=external, cn=auth&quot; read by dn.base=&quot;cn=admin,dc=sy,dc=com&quot; read by * none</p>
<p>ldapmodify -Y EXTERNAL -H ldapi:/// -f monitor.ldif
SASL/EXTERNAL authentication started
SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
SASL SSF: 0
modifying entry &quot;olcDatabase={1}monitor,cn=config&quot;</p>
<p>#复制ldap原有配置，并赋予它所有权限
cp /usr/share/openldap-servers/DB_CONFIG.example /var/lib/ldap/DB_CONFIG
chown ldap:ldap /var/lib/ldap/*</p>
<h4 id="添加基础库即三个基础结构的数据结构">添加基础库；即三个基础结构的数据结构</h4>
<h1 id="cosine-schema是一套基础且常用的schema集合包含了互联网上广泛认可的标准属性和类定义如电子邮件相关属性组织和人员信息等">Cosine schema是一套基础且常用的schema集合，包含了互联网上广泛认可的标准属性和类定义，如电子邮件相关属性、组织和人员信息等；</h1>
<h5 id="nis-schema扩展了ldap目录的能力使其能够支持和兼容原本在nis系统中使用的数据结构如用户组主机名等信息使得从nis迁移至ldap或者在ldap中模拟nis环境变得可能">NIS Schema扩展了LDAP目录的能力，使其能够支持和兼容原本在NIS系统中使用的数据结构，如用户、组、主机名等信息，使得从NIS迁移至LDAP或者在LDAP中模拟NIS环境变得可能；</h5>
<h5 id="inetorgperson是一个标准的ldap对象类别objectclass它是基于x520目录模型并扩展了person类别专为存储互联网和个人相关信息而设计它包括了许多与人相关的属性如电子邮件地址电话号码职务部门等非常适合用于存储和管理组织内的员工成员或联系人信息">inetOrgPerson是一个标准的LDAP对象类别（ObjectClass），它是基于X.520目录模型并扩展了person类别，专为存储互联网和个人相关信息而设计。它包括了许多与人相关的属性，如电子邮件地址、电话号码、职务、部门等，非常适合用于存储和管理组织内的员工、成员或联系人信息。</h5>
<p>ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/cosine.ldif
SASL/EXTERNAL authentication started
SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
SASL SSF: 0
adding new entry &quot;cn=cosine,cn=schema,cn=config&quot;</p>
<p>ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/nis.ldif
SASL/EXTERNAL authentication started
SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
SASL SSF: 0
adding new entry &quot;cn=nis,cn=schema,cn=config&quot;</p>
<p>ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/inetorgperson.ldif
SASL/EXTERNAL authentication started
SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
SASL SSF: 0
adding new entry &quot;cn=inetorgperson,cn=schema,cn=config&quot;</p>
<p>vim /etc/openldap/slapd.d/base.ldif
dn: dc=sy,dc=com
dc: sy
objectClass: top
objectClass: domain</p>
<p>dn: cn=admin,dc=sy,dc=com
objectClass: organizationalRole
cn: admin
description: LDAP Manager</p>
<p>dn: ou=People,dc=sy,dc=com
objectClass: organizationalUnit
ou: People</p>
<p>dn: ou=Group,dc=sy,dc=com
objectClass: organizationalUnit
ou: Group</p>
<p>ldapadd -x -W -D &quot;cn=admin,dc=sy,dc=com&quot; -f base.ldif
Enter LDAP Password:<br>
adding new entry &quot;dc=sy,dc=com&quot;</p>
<p>adding new entry &quot;cn=admin,dc=sy,dc=com&quot;</p>
<p>adding new entry &quot;ou=People,dc=sy,dc=com&quot;</p>
<p>adding new entry &quot;ou=Group,dc=sy,dc=com&quot;</p>
<p>vim /etc/httpd/conf.d/phpldapadmin.conf</p>
<h1 id=""></h1>
<h1 id="web-based-tool-for-managing-ldap-servers">Web-based tool for managing LDAP servers</h1>
<h1 id="-1"></h1>
<p>Alias /phpldapadmin /usr/share/phpldapadmin/htdocs
Alias /ldapadmin /usr/share/phpldapadmin/htdocs</p>
<p>&lt;Directory /usr/share/phpldapadmin/htdocs&gt;
<IfModule mod_authz_core.c>
# Apache 2.4
Require all granted              #改为允许所有
</IfModule>
&lt;IfModule !mod_authz_core.c&gt;
# Apache 2.2
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
Allow from ::1
</IfModule>
</Directory></p>
<p>vim /etc/phpldapadmin/config.php</p>
<h1 id="找到找到398行把这里的uid改为cn">找到找到398行,把这里的uid改为cn</h1>
<p>$servers-&gt;setValue('login','attr','cn');</p>
<h1 id="找到460行把true改为false-关闭匿名登录">找到460行，把true改为false 关闭匿名登录</h1>
<p>$servers-&gt;setValue('login','anon_bind',false);</p>
<h1 id="找到519行设置用户属性的唯一性这里我将cn-sn给添加上">找到519行,设置用户属性的唯一性,这里我将cn sn给添加上</h1>
<p>$servers-&gt;setValue('unique','attrs',array('mail','uid','uidNumber','cn','sn'))</p>
<p>源自： <a href="https://blog.csdn.net/Kammingo/article/details/144670275">https://blog.csdn.net/Kammingo/article/details/144670275</a></p>
<h3 id="24-访问测试">2.4 访问测试</h3>
<pre><code>#重启httpd服务
service restart httpd
#访问测试
http://192.168.0.41/phpldapadmin

</code></pre>
<h2 id="3-ldap创建组织">3. LDAP创建组织</h2>
<ul>
<li>参考文档：<a href="https://www.cnblogs.com/mascot1/p/10498460.html">https://www.cnblogs.com/mascot1/p/10498460.html</a></li>
</ul>
<h3 id="31-创建ou">3.1 创建OU</h3>
<p><img src="file:///e:\Code\Jenkins\jenkinsdocs\chapter\static\image\06\01-ldap.png" alt="管理页面"></p>
<ul>
<li>
<p>选择Organisational unit 组织单元
<img src="file:///e:\Code\Jenkins\jenkinsdocs\chapter\static\image\06\01-ldap2.png" alt="管理页面"></p>
</li>
<li>
<p>输入OU名称
<img src="file:///e:\Code\Jenkins\jenkinsdocs\chapter\static\image\06\01-ldap3.png" alt="管理页面"></p>
</li>
<li>
<p>提交信息
<img src="file:///e:\Code\Jenkins\jenkinsdocs\chapter\static\image\06\01-ldap4.png" alt="管理页面"></p>
</li>
<li>
<p>查看结果
<img src="file:///e:\Code\Jenkins\jenkinsdocs\chapter\static\image\06\01-ldap5.png" alt="管理页面"></p>
</li>
</ul>
<h3 id="32-创建人员">3.2 创建人员</h3>
<ul>
<li>
<p>选择OU-&gt;选择新建子条目
<img src="file:///e:\Code\Jenkins\jenkinsdocs\chapter\static\image\06\01-ldap6.png" alt="管理页面"></p>
</li>
<li>
<p>选择默认模板
<img src="file:///e:\Code\Jenkins\jenkinsdocs\chapter\static\image\06\01-ldap7.png" alt="管理页面"></p>
</li>
<li>
<p>选择inetorgperson
<img src="file:///e:\Code\Jenkins\jenkinsdocs\chapter\static\image\06\01-ldap8.png" alt="管理页面"></p>
</li>
<li>
<p>填写并提交信息
<img src="file:///e:\Code\Jenkins\jenkinsdocs\chapter\static\image\06\01-ldap9.png" alt="管理页面"></p>
</li>
<li>
<p>用户创建完成
<img src="file:///e:\Code\Jenkins\jenkinsdocs\chapter\static\image\06\01-ldap10.png" alt="管理页面"></p>
</li>
</ul>
<h2 id="4jenkins集成ldap">4.Jenkins集成LDAP</h2>
<ul>
<li>参考文档：<a href="https://www.cnblogs.com/mascot1/p/10498513.html">https://www.cnblogs.com/mascot1/p/10498513.html</a></li>
</ul>
<h3 id="41-先决条件">4.1 先决条件</h3>
<ul>
<li>准备一个adminDN账号用于查询用户。 cn=Manager,dc=my-domain,dc=com</li>
<li>2.将访问Jenkins的用户放到一个OU中。 ou=jenkins,dc=my-domain,dc=com</li>
<li>3.提供ldap服务器地址。 ldap://192.168.0.41:389</li>
</ul>
<h3 id="42-jenkins配置">4.2 Jenkins配置</h3>
<ul>
<li>
<p>安装ldap插件
<img src="file:///e:\Code\Jenkins\jenkinsdocs\chapter\static\image\06\01-ldap11.png" alt="管理页面"></p>
</li>
<li>
<p>全局安全配置
<img src="file:///e:\Code\Jenkins\jenkinsdocs\chapter\static\image\06\01-ldap12.png" alt="管理页面"></p>
</li>
<li>
<p>选择账号测试，出现一下信息集成完毕
<img src="file:///e:\Code\Jenkins\jenkinsdocs\chapter\static\image\06\01-ldap13.png" alt="管理页面"></p>
</li>
</ul>
<h3 id="下一章---------------上一章"><a href="./%E7%AC%AC%E4%B8%83%E7%AB%A0-%E9%9B%86%E6%88%90Jenkins(%E4%B8%89).html">下一章</a>    &lt;---------&gt;  <a href="./%E7%AC%AC%E4%BA%94%E7%AB%A0-%E9%9B%86%E6%88%90Jenkins(%E4%B8%80).html">上一章</a></h3>

            <script async src="https://cdn.jsdelivr.net/npm/katex-copytex@latest/dist/katex-copytex.min.js"></script>
            
        </body>
        </html>